package cn.edu.ahpu.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import cn.edu.ahpu.pojo.Formula;
import cn.edu.ahpu.service.ComputeService;
import cn.edu.ahpu.utils.RandomGenerate;

@Service
public class ComputeServiceImpl implements ComputeService{

	/**运算符的数量**/
	private int len=3;
	
	/**要生成的运算式的数量**/
	private int count=20;
	
	/**
	 * 0~100整数四则运算
	 */
	@Override
	public List<Formula> createZeroToHundred() {
		List<Formula> list = new ArrayList<Formula>();
		
		for (int i = 0; i < count; i++) {
			Formula formula = RandomGenerate.randomZeroToHundred(len);
			boolean flag = RandomGenerate.checkFormula(formula);
			
			//没有生成需要的算式
			if(!flag) {
				continue;
			}
			
			formula.setId(i+1);
			list.add(formula);
		}
		
		return list;
	}

	@Override
	public List<Formula> createWithBracket() {
		
		
		
		
		return null;
	}
}
